package com.zhonglz.api.file;

import java.io.ByteArrayInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Base64;

import com.zhonglz.util.file.FileUtils;

/***
 * base64写入本地文件
 * @author zhonglz
 *
 */
public class TestBase64ToLocal {
	
	public static void main(String[] args) throws Exception {
		
		//文件  base64编码后的字符串
		// 
		String base64Str = "iVBORw0KGgoAAAANSUhEUgAAAJYAAACWCAYAAAA8AXHiAAAIHklEQVR42u2df4RWWRjHX+M1RhJrjIyxIskYK0NWkpHISJIxJMlYa0hWRjKMtcbKiiQZI5EkSSIrycqQZP9IljWSJMtaKyMjXhkjY7y8e856Lsdx7nt/v/e+934+PH/MvOf+eM793nvOee5zzq3VAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACKQ6tWu6LsgrIeaiOX+n+gbKKMjj1S1lL2j7LvuNQdrfuLUvfa5svm3KrhnLa3yo5U4KKeUHY9R7tj1XtLnl59ZajcrZZja3IXba2AsPqUvXBc3LztYRkq97jl1JWKNUVaXLd0M6T7OcpGOvnEUMd6ZtX/3VLc1MqJS5Zjo/R8Olr/prB+KZNjvxuOveFS5yqs6bI4VVfWNBy7wKVGWGk4NWE4pQU2xKVGWGk4ddNw6llGx+hJcV8DCKs7nFoxnDqdoPM/0Ob3bcqu6WY34bnOSgB3F8IqtkN7DYcaUS+89M+8iP2y3xBZ/X+LNzBQtjvBuTaNcz2QUZ3M5hAk/bdswjJfJSxG3FYHVZ9bYYrnLnGq//UaZb5IzChJ5WvbUHYygzoZdByrk1YKYb03HHoa8UL/6VMxD3yOlfYF2MxCWIa49GuV88qO6aY3aTNemaZQObAnw7vuWoCwTsY43ynraXWQPlYxnbnaLnal/nfYEsNEwuOlKaxPdN6L6UiPkc3wQfeBOiCsTYRVfmFNBjmSgbA2EFY6wlJlthfVEe/d4Os2ZRBWAYWlft8vaU0zRXNi1HBiDGF1j7AMUXllZ4rkxD05qdsB5R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0bhCV9oElrwd+WTEQZTBJucJQfsBa+24w76i6yqL4N+7Sy+gotx8cHhhxlN4osLJ0GLOuFrTia+dGQ+4g8mUKeivYsooXSBE2VIy/jfBXBWrXGsxsBwlqKkXhoTupsptgZn/b5MsVK1KUz487S0U95x+sj3RqMdLuoTlvpIUMRtt0mrzvsHKJ6G2EltgS+1iUl6KHjYnqvXC6nlJocJRxzwudcLnXlVyokbrUaNjUkRIjCs8MZNoWtiNv2yYW7HyDwF0lesySdV6jrpU2a91xXCUzu3ERZDNLh/dt+DWSV2cxDWJJX1gx4AuoLdyqFukw8YVWySL/4nOe6dAvGii4qM2lf5wptS7CvqYCmsJWTsHolLcVPVPeizLcMONZEGjOhZQGQ1YCboSEPhVk57sGiiGrUuDNWkn6RQp5a3juzO47fUxVWlBx8HV9zXJjPaS+O68iXP5ZgX1/7pEj72eciiMqMn6ymlbUo06Warv3lKSzZfsH6yOeuCNsuSnbnXclDn5JP8Y3Lispb5e9Gu+5ADJ97rfmFrs69PqdDuX9yWZ3AV8ZL0JW0U2Fd8S9rnfe0hLUl4vZ90g98GbXJl8yOeZmCFfYJ0kxx6v5hY0KtGV8rxlxDEdUrI04y2KHjbrEyMfcnEJZuvm/ECSBKk9if0JeDjg8nhF7vPmHM7aoItjhzDKX5W/ZSjTt5YhLrWpbBQj3BXTuXZICRsk/jRtqMq2O9I6PjDpsZFXlXwi55lOq7/VwOx++plRC5Wd86XmkdqpUdia00JPi3swZZ3LSbxjT4PVVwui59qkkkkGk9L0o8qU5tAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAKfkPqnr0uar1AhsAAAAASUVORK5CYII=";
		
		byte[] bt = Base64.getDecoder().decode(base64Str);//解码
		InputStream is = new ByteArrayInputStream(bt);
		String name ="test.png";//文件带后缀
		String path="C:\\Users\\Administrator\\Desktop\\"+name ;
		FileUtils.writeToLocal(path, is);
	}

}
